﻿package com.bizmlib.controls
{
	import flash.display.MovieClip;
	import flash.geom.ColorTransform;
	import com.bizmlib.ui.composite.*;
	
	
	public class ColorPickerSwatch extends UICompositionItem
	{
		public static const WIDTH:Number = 8;
		public static const HEIGHT:Number = 8;
		
		private var noColorIcon:MovieClip;
		
		
		override protected function afterInit():void
		{
			//toggle = false;
		}
		override protected function initClickArea(shouldCreate:Boolean = true):void
		{
			area = new ColorPicker_swatchSkin();
			addChild(area);
			
			super.initClickArea(false);
		}
		
		override protected function afterUpdate():void
		{
			if(dataProvider.color<0)
			{
				if(!noColorIcon)
				{
					noColorIcon = new ColorPicker_noColorIcon();
					addChild(noColorIcon);
					noColorIcon.mouseEnabled = false;
					noColorIcon.mouseChildren = false;
				}
				noColorIcon.width = area.width;
				noColorIcon.height = area.height;
			}
			else
			{
				if(noColorIcon)
				{
					removeChild(noColorIcon);
				}
				var colorTransform:ColorTransform = new ColorTransform();
				colorTransform.color = dataProvider.color;
				area.transform.colorTransform = colorTransform;
			}
		}
	}
}